
// C++
#include <iostream>
// OpenCV
#include <opencv2/opencv.hpp>
// Kinect DK
#include <k4a/k4a.hpp>
 
// 宏
// 方便控制是否 std::cout 信息
#define DEBUG_std_cout 0
#include "record_k4a_image.h"
#include <fstream>
#include <iostream>

static RecordImage s_record;
static const char* s_fileName = "depth.data";
//static const char* s_fileName = "rgb.data";
void readFile()
{
    std::ifstream is;
    if (is.bad())
    {
        std::cout << "cannot open file" << std::endl;
        return;
    }
    is.open(s_fileName, std::ios::in | std::ios::binary);

    is.seekg(0, is.end);
    uint32_t length = is.tellg();
    is.seekg(0, is.beg);

    while(!is.eof())
    {
        uint32_t len = 0;
        is.read((char*)&len, 4);
        if (len < 1000) // 应该不会小于1000吧
            break;

        std::vector<char> vec;
        vec.resize(len);
        is.read((char*)&vec[0], len);
        BytesBuffer out;
        s_record.decompress(vec, &out);
        s_record.showDebugImage(&out, kImageType_depth);
        //s_record.showDebugImage(&out, kImageType_rgb);
    }
}


int main(int argc, char* argv[])
{
    readFile();
 
	return 0;
}
